package cn.cvs.web.interceptor;

import cn.cvs.utils.Constants;
import org.apache.ibatis.plugin.Intercepts;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SysInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.err.println("========================>:进入了自定义拦截器 SysInterceptor" );

        if (null == request.getSession().getAttribute(Constants.userSession)){
            request.getRequestDispatcher("tologin").forward(request,response);
            return false;
        }
        return true;
    }

}
